<template>	
		<!-- 顶部导航栏 -->
		<view class="nav-bar">
			<!-- <view class="back-icon" @click="goBack">
				<text class="iconfont">&#xe8b5;</text>
			</view> -->
			<view>
				<image class="back" src="/static/images/白色左箭头.png" mode="" @click="goBack"></image>
			</view>
			<text class="nav-title">优惠券</text>
		</view>

		<!-- 优惠券列表 -->
		<view class="coupon-list">
			<view 
				class="coupon-wrapper"
				v-for="(coupon, index) in coupons" 
				:key="index"
			>
				<image 
					src="/static/home/wash/椭圆 3 拷贝@2x.png" 
					mode="widthFix" 
					class="coupon-bg"
				/>
				<view class="coupon-content">
					<view class="coupon-left">
						<text class="limit-text">{{ coupon.type }}</text>
						<text class="condition-text">满{{ coupon.condition }}元可用</text>
						<text class="date-text">有效期至：{{ coupon.validity }}</text>
					</view>
					<view class="coupon-right">
						<view class="amount">
							<text class="symbol">¥</text>
							<text class="number">{{ coupon.amount }}</text>
						</view>
						<view class="use-btn" @click="useCoupon(coupon)">
							去使用 >
						</view>
					</view>
				</view>
			</view>
		</view>
</template>

<script setup>
import { ref } from 'vue';

const coupons = ref([
	{
		type: '仅限于XX加油站使用',
		condition: 200,
		amount: 20,
		validity: '2020.04.11—2023.05.11'
	},
	{
		type: '通用',
		condition: 200,
		amount: 20,
		validity: '2020.04.11—2023.05.11'
	},
	{
		type: '仅限于XX加油站使用',
		condition: 200,
		amount: 20,
		validity: '2020.04.11—2023.05.11'
	}
]);

const goBack = () => {
	uni.navigateBack();
};

const useCoupon = (coupon) => {
	// 处理使用优惠券逻辑
	console.log('使用优惠券', coupon);
};
</script>

<style scoped>
.back {
		position: absolute;
		left: 30rpx;
		top: 40rpx;
		width: 15px;
		height: 15px;
		z-index: 2;
	}

.nav-bar {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0 30rpx;
	background: #4080FF;
	color: #fff;
}

.back-icon {
	font-size: 40rpx;
}

.nav-title {
	font-size: 34rpx;
	font-weight: 500;
	margin: 30rpx 0;
}

.right-icons {
	display: flex;
	gap: 20rpx;
}

.icon {
	width: 48rpx;
	height: 48rpx;
}

.coupon-list {
	padding: 30rpx;
}

.coupon-wrapper {
	position: relative;
	margin-bottom: 30rpx;
}

.coupon-bg {
	width: 100%;
	height: auto;
	display: block;
}

.coupon-content {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 30rpx;
}

.coupon-left {
	display: flex;
	flex-direction: column;
	gap: 10rpx;
}

.limit-text {
	font-size: 24rpx;
	color: #FFFFFF;
}

.condition-text {
	font-size: 32rpx;
	color: #FFFFFF;
	font-weight: 500;
}

.date-text {
	font-size: 24rpx;
	color: rgba(255, 255, 255, 0.8);
	margin-top: 20rpx;
}

.coupon-right {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 30rpx;
}

.amount {
	display: flex;
	align-items: baseline;
	color: #FFFFFF;
}

.symbol {
	font-size: 32rpx;
	margin-right: 4rpx;
}

.number {
	font-size: 64rpx;
	font-weight: bold;
}

.use-btn {
	font-size: 28rpx;
	color: #FFFFFF;
	padding: 10rpx 0;
}
</style>
